package com.dhecp.project.system.controller;

import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.project.business.domain.IndexImage;
import com.dhecp.project.business.service.IndexImageService;
import com.dhecp.project.oa.domain.Notice;
import com.dhecp.project.oa.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @program: kjecp
 * @description: 首页数据
 * @author: hlf
 * @create: 2023-06-01 09:16
 */
@Controller
@RequestMapping("/system/index")
public class SysIndexController extends BaseController {

    @Autowired
    private IndexImageService indexImageService;


    @Autowired
    private NoticeService noticeService;

    /**
     * 查询页 列表数据
     * @param params
     * @return
     * @author DH-Xxj
     */
//    @RequiresPermissions("business:indeximage:list")
    @GetMapping("/image")
    @ResponseBody
    public TableDataInfo image(@RequestParam Map<String, Object> params){
        params.put("moduleTable", ModuleTable.INDEX_IMAGE);
        List<IndexImage> list = new ArrayList<IndexImage>();
        try {
            list = indexImageService.queryList(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());
        }
        return getDataTable(list);
    }

    /**
     * 查询页 列表数据
     * @param params
     * @return
     * @author DH-Xxj
     */
//    @RequiresPermissions("oa:notice:list")
    @GetMapping("/notice")
    @ResponseBody
    public TableDataInfo notice(@RequestParam Map<String, Object> params){
        params.put("moduleTable", ModuleTable.NOTICE);
        List<Notice> list = new ArrayList<Notice>();
        try {
            list = noticeService.queryList(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());
        }
        return getDataTable(list);
    }
}